<template>
  <div class="container">
    <!-- <img src="../assets/img/9.jpg" alt=""> -->
    <!--<slider speed='2000'></slider>-->
    <h3 class="alert alert-info">作业列表</h3>
     <div class="btn"><button><router-link to="/topic">添加作业题目 </router-link></button></div>
    <table class="table table-bordered" style="margin-top: 80px">
      <thead style="text-align: center">
        <tr>
          <th>作业号</th>
          <th>作业名称</th>
          <th>创建时间</th>
          <th>结束时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(list, index) in lists" :key="index">
          <td>{{ list.homeworkId }}</td>
          <td><router-link to="/#">
            {{ list.homeworkName }}
          </router-link></td>
          <td>{{ list.homeworkStartTime }}</td>
          <td>{{ list.homeworkEndTime }}</td>
          <td>
           <el-button type="text" @click="open"> <i class="icon icon-trash"></i></el-button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>
<script>
//import Slider from '../components/Slider.vue';
export default {
  name: "homework",
  data() {
    return {
      lists: [],
    };
  },
  components: {
    //Slider,
  },
    methods: {
      open() {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      }
    },

  mounted() {
    this.$axios
      .get("http://10.197.26.58:8001/gethomework")
      .then((response) => {
        this.lists = response.data.slice(0, 100);
        console.log(this.lists);
      })
      .catch(function (error) {
        //请求失败处理
        console.log(error);
      });
  },
};
</script>

